page.tsx 708 B

12345678910111213141516171819202122232425262728
  1. "use client";
  2. import { useEventPoint } from "@/hooks/useEventPoint";
  3. import { usePathname } from "@/i18n/routing";
  4. import { useEffect } from "react";
  5. /**
  6. * @description 主页初始化
  7. */
  8. const Page = () => {
  9. useEventPoint();
  10. // 获取分享id
  11. const pathname = usePathname();
  12. useEffect(() => {
  13. localStorage.setItem("channel_code", window.location.href);
  14. const [, shareId] = pathname.split("/");
  15. if (!shareId || shareId === "xxxxxx") return;
  16. if (shareId.length !== 8) {
  17. sessionStorage.removeItem("shareId");
  18. return;
  19. }
  20. sessionStorage.setItem("shareId", shareId);
  21. }, []);
  22. return null;
  23. };
  24. export default Page;